package com.xbongbong.pro.statistic.service.impl;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.StringUtil;
import com.xbongbong.pro.detailtab.dto.RemindDTO;
import com.xbongbong.pro.detailtab.vo.RemindVO;
import com.xbongbong.pro.statistic.help.RemindHelp;
import com.xbongbong.pro.statistic.service.RemindService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 提示实现类
 *
 * @author 徐俊杰
 * @version v1.0
 * @date 2019/6/3 10:02
 * @since v1.0
 */
@Service("remindService")
public class RemindServiceImpl implements RemindService {
    @Resource
    private RemindHelp remindHelp;

    @Override
    public RemindVO remindCustomer(RemindDTO remindDTO) throws XbbException {
        RemindVO remindVO = new RemindVO();
        List<String> remindList = remindVO.getRemindList();
        //客户最后联系时间
        String remindCustomer = remindHelp.customerRemind2Customer(remindDTO);
        checkEmpty(remindList, remindCustomer);
        //机会提示
        String remindOpportunity = remindHelp.customerRemind2Opportunity(remindDTO);
        checkEmpty(remindList, remindOpportunity);
        //访客计划提示
        String remindCommunicatePlan = remindHelp.customerRemind2CommunicatePlan(remindDTO);
        checkEmpty(remindList, remindCommunicatePlan);
        //最近7天客户跟进提醒条数
        String remindCustomerCommunicate = remindHelp.customerRemind2Push(remindDTO);
        checkEmpty(remindList, remindCustomerCommunicate);
        //客户即将退回公海池提示
        String remindReturnToPublic = remindHelp.customerRemind2ReturnToPublic(remindDTO);
        checkEmpty(remindList, remindReturnToPublic);
        //有N个合同将于30天内到期
        String remindContract = remindHelp.customerRemind2Contract(remindDTO);
        checkEmpty(remindList, remindContract);
        //有N笔回款将于30天内收款
        String remindPayment = remindHelp.customerRemind2Payment(remindDTO);
        checkEmpty(remindList, remindPayment);
        //有N个报价单将于30天内到期
        String remindQuotation = remindHelp.customerRemind2Quotation(remindDTO);
        checkEmpty(remindList, remindQuotation);
        return remindVO;
    }

    /**
     * 检查单条提示是否为空
     *
     * @param remindList 提示列表
     * @param remind     单条提示
     * @author 徐俊杰
     * @date 2019/6/6 10:41
     * @since v1.0
     */
    private void checkEmpty(List<String> remindList, String remind) {
        if (!StringUtil.isEmpty(remind)) {
            remindList.add(remind);
        }
    }
}
